package com.ruoyi.controller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.service.RPService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel/rp")
public class RPController extends BaseController {

    @Autowired
    RPService rpService;

    /**
     * 批量修改采购价
     */
    @PostMapping("/postPriceEnter")
    public AjaxResult postPriceEnter(@RequestBody Map map) {
        return toAjax(rpService.postPriceEnter(map));
    }

    /**
     * 修改产品维度的数据
     *
     * @param jsonObject
     * @return
     */
    @PostMapping("/postUpdateRpDimension")
    public AjaxResult postUpdateRpDimension(@RequestBody JSONObject jsonObject) {
        return rpService.postUpdateRpDimension(jsonObject);
    }

    @GetMapping("/getRpList")
    public AjaxResult getRpList(@RequestParam Map map) {
        return success(rpService.getRpList(map));
    }

    /**
     * 产品上线
     *
     * @param jsonObject
     * @return
     */
    @PostMapping("/goOnline")
    public AjaxResult goOnline(@RequestBody JSONObject jsonObject) {
        return rpService.goOnline(jsonObject);
    }

    /**
     * 产品下线
     *
     * @param jsonObject
     * @return
     */
    @PostMapping("/postShelvesRp")
    public AjaxResult postShelvesRp(@RequestBody JSONObject jsonObject) {
        return rpService.postShelvesRp(jsonObject);
    }

    /**
     * 获取这个订单对应的订单信息、订单采购价、订单对应酒店信息、订单操作日期、获取订单发单模板
     *
     * @param map
     * @return
     */
    @GetMapping("/getRpPriceAndHotelObj")
    public AjaxResult getRpPriceAndHotelObj(@RequestParam Map map) {
        return success(rpService.getRpPriceAndHotelObj(map));
    }

    /**
     * 根据订单ID获取采购价
     *
     * @param map
     * @return
     */
    @GetMapping("/getCgjByOrderId")
    public AjaxResult getCgjByOrderId(@RequestParam Map map) {
        return success(rpService.getCgjByOrderId(map));
    }

    @PostMapping("/postYueYouEditCgj")
    public AjaxResult postYueYouEditCgj(@RequestBody JSONObject jsonObject) {
        JSONArray jsonArray = jsonObject.getJSONArray("fjdj");
        String orderId = jsonObject.getString("orderId");
        return toAjax(rpService.postYueYouEditCgj(orderId, jsonArray));
    }
}
